import { onMounted, ref } from 'vue'
import { useRoute } from 'vue-router'
import { getConsultOrderDetail } from '@/api/consult'
import type { ConsultOrderItem } from '@/types/consult'
const useOrderDetail = () => {
  const route = useRoute()
  // 1. 订单详情数据
  const item = ref<ConsultOrderItem>()
  // 2. 获取订单数据函数
  const getConsult = async (id: string) => {
    const data = await getConsultOrderDetail(id)
    console.log('问诊订单详情：', data)
    item.value = data
  }
  onMounted(() => {
    getConsult(route.params.id as string)
  })

  return { item, getConsult, route }
}

export { useOrderDetail }
